package com.polaris.live.dialog.common

import android.content.Context
import com.lxj.xpopup.core.CenterPopupView
import com.polaris.live.R
import com.polaris.live.databinding.DialogConfirmCanalBinding
import com.polaris.live.common.ext.setOnSingleClickListener

/**
 * 通用的确定取消弹窗
 *
 * @author Created by 半仙 on 2023/11/6/006 10:16
 */
class ConfirmCanalDialog(
    context: Context,
    private val title: String,
    private val mConfirm: String? = null,
    private val mCanal: String? = null,
    private val onConfirmCallback: (() -> Unit)? = null,
    private val onCanalCallback: (() -> Unit)? = null,
) :
    CenterPopupView(context) {
    override fun getImplLayoutId(): Int {
        return R.layout.dialog_confirm_canal
    }

    private lateinit var mBinding: DialogConfirmCanalBinding

    override fun onCreate() {
        super.onCreate()
        mBinding = DialogConfirmCanalBinding.bind(popupImplView)
        mBinding.tvConfirm.setOnSingleClickListener {
            onConfirmCallback?.invoke()
            dismiss()
        }
        mBinding.tvCancel.setOnSingleClickListener {
            onCanalCallback?.invoke()
            dismiss()
        }
        mBinding.tvTitle.text = title
        if (mConfirm != null) {
            mBinding.tvConfirm.text = mConfirm
        }
        if (mCanal != null) {
            mBinding.tvCancel.text = mCanal
        }
    }
}